package com.william.lifetraxer.utils;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;

public class Track {
	@XmlAttribute
	public String date = null;
	
	@XmlAttribute
	public String username = null;
	
	@XmlAttribute
	public int groupid = 0;
	
	@XmlAttribute
	public int type = 0;
	
	@XmlElement(name="point")
	List<Point> points = new ArrayList<Point>();
	
	public Track()
	{
		this(null,null,0,0,null);
	}
	
	public Track(List<Point> points){
		this.points=points;
	}
	
	public Track(String date , String username , int groupid , int type , List<Point> points)
	{
		this.date=date;
		this.username=username;
		this.groupid=groupid;
		this.points=points;
		this.type=type;
	}
	
	public int length(){
		return this.points.size();
	}
	
	public Point[] toPointArray(){
		return this.points.toArray(new Point[]{});
	}
	
	public void set(int index , Point point){
		this.points.set(index, point);
	}
	
	public Point get(int index){
		return this.points.get(index);
	}
	
	public void appendTrack(Track appendTrack){
		this.points.addAll(appendTrack.points);
	}
}
